package cn.edu.ctbu.demo2.domain;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;


/*
针对tb-student的实体类
*/
@Data
@Entity(name="tb_student")
public class Student {
    @Id
//    mysql中的自增
    @GeneratedValue  (strategy = GenerationType.IDENTITY)
    private Integer id;

    //学号
    @NotNull(message = "学号不能为空")
    @Size(min=10,max=10,message = "学号必须为十位")
    private String no;

    //姓名
    @NotNull(message = "姓名不能为空")
    @Size(min=2,max=20,message = "姓名长度必须为2~20个字符")
    private String name;

    //密码
    @NotNull(message = "密码不能为空")
    private String password;

    //性别
    private Integer sex;

    //年龄
    @NotNull(message = "年龄不能为空")
    @Max(value = 70,message = "年龄必须小于70岁")
    @Min(value = 8,message ="年龄必须大于8岁" )
    private Integer age;

}
